<template>
	<!-- 优惠详情 -->
	<CustomNavbar>
		<view class="navbar-content">
			<!-- 左侧返回按钮 -->
			<view class="nav-left" @click="goBack">
				<text class="back-icon">‹</text>
			</view>
			<!-- 中间标题 -->
			<view class="nav-title">团购优惠</view>

		</view>
	</CustomNavbar>

	<!-- 详情内容 -->
	<view class="detail-container">
		<view class="detail-card">
			<!-- 标题 -->
			<view class="detail-title">{{ detailData.title }}</view>

			<!-- 来源和日期 -->
			<view class="detail-meta">
				<text class="detail-source">{{ detailData.source }}</text>
				<text class="detail-date">{{ detailData.date }}</text>
			</view>

			<!-- 横幅图片 -->
			<view class="detail-banner-wrapper">
				<image :src="detailData.banner" class="detail-banner" mode="aspectFill" />
			</view>

			<!-- 详细描述 -->
			<view class="detail-description">
				<text class="description-text">{{ detailData.description }}</text>
			</view>

			<!-- 价格和信息区域 -->
			<view class="detail-info-box">
				<view class="info-row price-row">
					<text class="info-label">价格:</text>
					<view class="price-wrapper">
						<text class="info-price">¥{{ detailData.price }}</text>
						<text class="info-original-price">原价:¥{{ detailData.originalPrice }}</text>
					</view>
				</view>
				<view class="info-row">
					<text class="info-label">活动起止日期:</text>
					<text class="info-value">{{ detailData.activityDate }}</text>
				</view>
				<view class="info-row">
					<text class="info-label">咨询电话:</text>
					<text class="info-value">{{ detailData.phone }}</text>
				</view>
				<view class="info-row">
					<text class="info-label">注意事项:</text>
					<text class="info-value">{{ detailData.notes }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import CustomNavbar from '@/components/CustomNavbar.vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'

	// 返回按钮
	const goBack = () => {
		uni.navigateBack()
	}

	// 优惠详情数据列表
	const discountDetailList = {
		1: {
			title: '汽车惠民活动走进焦作市山阳区',
			source: '济源某某汽车行业',
			date: '2023/3/10 11:09',
			banner: '/static/10011.jpg',
			description: '哇噻!薅羊毛的看过来!易车修汽车维修服务中心出优惠团购了!纯手工洗车只要25元一次,还增20元油券,够意思了吧!',
			price: '99.00',
			originalPrice: '199.00',
			activityDate: '2023-3-10 08:00 至 2023-3-18 23:59',
			phone: '0379-66666666',
			notes: '暂无'
		},
		2: {
			title: '冬季车辆保养特惠套餐限时抢购',
			source: '济源某某汽车行业',
			date: '2023/3/11 10:30',
			banner: '/static/10015.jpg',
			description: '冬季来临，为您的爱车提供全方位的保养服务。包含机油更换、防冻液添加、空调系统检查等多项服务，让您的爱车温暖过冬！',
			price: '299.00',
			originalPrice: '399.00',
			activityDate: '2023-3-11 09:00 至 2023-3-20 23:59',
			phone: '0379-66666666',
			notes: '活动期间内有效，需提前预约'
		},
		3: {
			title: '洗车+打蜡组合套餐立减50元',
			source: '济源某某汽车行业',
			date: '2023/3/12 14:20',
			banner: '/static/10040.jpg',
			description: '专业洗车服务，采用高品质洗车用品，让您的爱车焕然一新。同时包含打蜡服务，保护车漆，延长使用寿命！',
			price: '128.00',
			originalPrice: '178.00',
			activityDate: '2023-3-12 08:00 至 2023-3-25 23:59',
			phone: '0379-66666666',
			notes: '限时优惠，数量有限，先到先得'
		},
		4: {
			title: '92号汽油充值1000送100元',
			source: '济源某某汽车行业',
			date: '2023/3/13 16:45',
			banner: '/static/10043.jpg',
			description: '92号汽油充值优惠活动，充值1000元即可获得100元赠送金额，让您的出行更加经济实惠！',
			price: '1000.00',
			originalPrice: '1100.00',
			activityDate: '2023-3-13 00:00 至 2023-3-30 23:59',
			phone: '0379-66666666',
			notes: '充值金额不设上限，多充多送'
		}
	}

	// 详情数据
	const detailData = ref({
		title: '汽车惠民活动走进群众生活',
		source: '济源某某汽车行业',
		date: '2023/3/10 11:09',
		banner: '/static/10011.jpg',
		description: '哇噻!薅羊毛的看过来!易车修汽车维修服务中心出优惠团购了!纯手工洗车只要25元一次,还增20元油券,够意思了吧!',
		price: '99.00',
		originalPrice: '199.00',
		activityDate: '2023-3-10 08:00 至 2023-3-18 23:59',
		phone: '0379-66666666',
		notes: '暂无'
	})

	// 页面加载时获取ID并加载对应的详情数据
	onLoad((options) => {
		if (options.id) {
			const id = parseInt(options.id)
			// 根据ID加载对应的详情数据
			if (discountDetailList[id]) {
				detailData.value = discountDetailList[id]
			} else {
				// 如果ID不存在，使用默认数据
				console.warn('未找到ID为', id, '的优惠详情，使用默认数据')
			}
		}
	})
</script>

<style scoped>
	/* 导航栏内容样式 */
	.navbar-content {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 88rpx;
		position: relative;
		margin: 0 -24rpx;
		padding: 0 24rpx;
	}

	.nav-left {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 60rpx;
		height: 88rpx;
	}

	.back-icon {
		color: #fff;
		font-size: 56rpx;
		font-weight: 300;
		line-height: 88rpx;
		transform: scaleY(1.3);
		cursor: pointer;
	}

	.nav-title {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		text-align: center;
		color: #fff;
		font-size: 36rpx;
		font-weight: bold;
		line-height: 88rpx;
	}


	/* 详情容器 */
	.detail-container {
		/* background-color: #f5f5f5; */
		min-height: calc(100vh - 176rpx);
		padding: 20rpx;
		position: absolute;
		top: 200rpx;
	}

	.detail-card {
		background-color: #fff;
		border-radius: 16rpx;
		padding: 30rpx;
		box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
	}

	/* 标题 */
	.detail-title {
		font-size: 36rpx;
		color: #333;
		font-weight: bold;
		line-height: 50rpx;
		margin-bottom: 20rpx;
	}

	/* 来源和日期 */
	.detail-meta {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid #f0f0f0;
	}

	.detail-source {
		font-size: 26rpx;
		color: #999;
	}

	.detail-date {
		font-size: 26rpx;
		color: #999;
	}

	/* 横幅图片 */
	.detail-banner-wrapper {
		width: 100%;
		height: 420rpx;
		border-radius: 12rpx;
		overflow: hidden;
		margin-bottom: 30rpx;
		background-color: #f5f5f5;
	}

	.detail-banner {
		width: 100%;
		height: 100%;
	}

	/* 详细描述 */
	.detail-description {
		margin-bottom: 30rpx;
		padding-bottom: 20rpx;
	}

	.description-text {
		font-size: 28rpx;
		color: #333;
		line-height: 44rpx;
	}

	/* 信息区域 */
	.detail-info-box {
		background-color: #f7f8fa;
		border-radius: 12rpx;
		padding: 30rpx;
	}

	.info-row {
		display: flex;
		align-items: flex-start;
		margin-bottom: 24rpx;
	}

	.info-row:last-child {
		margin-bottom: 0;
	}

	.info-label {
		font-size: 28rpx;
		color: #333;
		margin-right: 20rpx;
		width: 180rpx;
		flex-shrink: 0;
	}

	.price-row {
		align-items: center;
	}

	.price-wrapper {
		display: flex;
		align-items: baseline;
		flex: 1;
	}

	.info-price {
		font-size: 36rpx;
		color: #ff4d4f;
		font-weight: bold;
		margin-right: 16rpx;
	}

	.info-original-price {
		font-size: 24rpx;
		color: #999;
		text-decoration: line-through;
	}

	.info-value {
		font-size: 28rpx;
		color: #666;
		flex: 1;
		line-height: 40rpx;
	}
</style>